#!/usr/bin/env python3

import pywifi
import time


def wifi_find():
    wifi = pywifi.PyWiFi()
    card = wifi.interfaces()[0]
    card.scan()
    wifi_list = card.scan_results()
    for x in wifi_list:
        if x.ssid == "Huas_Student":
            return 1
    return 0


def wifi_interlinkage():
    wifi = pywifi.PyWiFi()  # 创建一个对象
    card = wifi.interfaces()[0]  # 选取一个网卡
    print(card.name())  # 输出网卡名称
    while card.status() == pywifi.const.IFACE_CONNECTED:
        card.disconnect()  # 断开现有连接
        time.sleep(1)

        profile = pywifi.Profile()
        profile.ssid = "Huas-Student"

        card.connect(card.add_network_profile(profile))